package com.itheima.api.map.demo04;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class MapDemo01 {

    public static void main(String[] args) {

        Map<String, String> map = new HashMap<String, String>();

        map.put("杨过", "小龙女");
        map.put("乔峰", "阿朱");
        map.put("段誉", "王语嫣");

        /**
         * V get(Object key)根据键获取值
         * Set<K> keySet()获取所有键的集合
         * Collection<V> values()获取所有值得集合
         */
        //V get(Object key)根据键获取值
        System.out.println(map.get("杨过"));
        System.out.println(map.get("虚竹"));

        System.out.println("-------------------------------------");

        //Set<K> keySet() 获取所有键的集合
        Set<String> keySet = map.keySet();
        keySet.forEach(s -> System.out.println(s));

        System.out.println("-------------------------------------");

        //Collection<V> values()获取所有值得集合
        Collection<String> col = map.values();
        for(String c : col) {
            System.out.println(c);
        }

        System.out.println("------------------------------------");

        System.out.println(map);

    }

}
